import request from '@/utils/request'

// 添加角色
export const addRoles = (data) => {
  return request({
    method: 'post',
    url: '/private/v1/roles',
    data,
  })
}
// 获取单个角色信息
export const getRolesDetail = (id) => {
  return request({
    method: 'get',
    url: '/private/v1/roles/' + id,
  })
}
// 编辑角色
export const editRoles = (id, data) => {
  return request({
    method: 'put',
    url: '/private/v1/roles/' + id,
    data,
  })
}
// 删除角色
export const delRoles = (id) => {
  return request({
    method: 'delete',
    url: '/private/v1/roles/' + id,
  })
}
// 获取角色树
export const getRolesTree = () => {
  return request({
    method: 'get',
    url: '/private/v1/rights/tree',
  })
}
// 分配权限
export const allotRolesRoot = (id, data) => {
  return request({
    method: 'post',
    url: `/private/v1/roles/${id}/rights`,
    data,
  })
}
// 删除角色指定权限
export const delRolesRoot = (roleId, rightId) => {
  return request({
    method: 'delete',
    url: `/private/v1/roles/${roleId}/rights/${rightId}`,
  })
}
// 获取权限列表
export const getRolesList = () => {
  return request({
    method: 'get',
    url: '/private/v1/rights/list',
  })
}
